<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var str = "nice to meet you";
    //str.slice(start,end)
    //截取字符串包含start位置字符
    //不包含end位置字符
    var childStr = str.slice(0,4);
    console.log(childStr);
    var str1 = str.slice(0,7);
    console.log(str1);
    //str.slice(start)
    //截取结果为从截取起始到整个字符串结束
    var str2 = str.slice(1);
    console.log(str2);

    //设定负值，表示从右向左，确定索引位置
    var str3 = str.slice(-3);
    console.log(str3);
    
</script>
</html>